<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath() + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=path%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>回报设置</title>
    <meta charset="UTF-8">
    <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
    <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"/>
    <link href="css/reg.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="css/base.css" type="text/css"/>
    <link rel="stylesheet" href="css/headbott.css" type="text/css"/>
    <link rel="stylesheet" href="css/index.css" type="text/css"/>
    <link rel="stylesheet" href="css/ly-list.css" type="text/css"/>
    <link rel="stylesheet" href="css/reg.css" type="text/css"/>
    <link rel="stylesheet" href="css/back.css" type="text/css"/>
    <title>Title</title>
</head>
<body>
<div id="header">
<%@include file="/WEB-INF/view/navigation.jsp"%>
</div>
<!--中间-->
<div class="product">
    <!--头上表格-->
  <%@include file="/WEB-INF/view/product/select.jsp" %>
    <!--下部foem表单-->
    <div class="product-form">
        <!--上标题-->
        <div class="product-title">
            <div class="my-h4">
                <h4>设置你的回报信息</h4>
            </div>
            <div class="btn-save">
                <button onclick="save()" class="btn btn-default">保存草稿</button>
            </div>

        </div>
        <div class="clear"></div>
        <hr>
        <!--描述项目-->
        <div class="product-title">
            <div class="my-h4">
                <h4><b>回报</b></h4>
            </div>
        </div>
        <div class="clear"></div>
        <hr>
        <!--编辑信息表单-->
        <form id="form" method="post"  >
            <div class="my-form">
                <div class="back">
                    <b>回报类型：</b>
                    <label class="radio-inline">
                        <input type="radio" name="type" id="optionsRadios3" value="实物回报(回报需邮寄)" checked> <b>实物回报(回报需邮寄)</b>
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="type"  id="optionsRadios4"  value="虚拟回报(回报无需邮寄)"> <b>虚拟回报(回报无需邮寄)</b>
                    </label>
                </div>
                <div class="back"><b>支持金额：</b><input value="${productReport.money }" name="money" id="money" class="input-mon"  placeholder="输入需要用户支持的金额">元</div>
                <div class="back"><b>具体规则：</b>每 <input value="${productReport.regular }" name="regular" id="regular" class="input-per" placeholder="此项必填"> 支持者抽出1名中奖者</div>
                <div class="back"><b>回报内容：</b><div><textarea  name="content" id="content" rows="2" placeholder="一句话介绍一下你的项目吧">${productReport.content }</textarea></div></div>
                <div class="back"><b>人数上限：</b><input value="${productReport.mixNumber }" name="mixNumber" class="input-num" placeholder="0">个<small>"0"为不需要名额</small></div>
                <div class="back"><b>回报时间：</b><input value="${productReport.time }" name="time" class="input-num" placeholder="0">天<small>"0"为开奖后立即发送</small></div>
                <div class="clear"></div>
                <hr>
                <!-- <div class="text-center"><button class="btn btn-primary">删除</button><button class="btn">保存</button></div><br> -->
            </div>
        </form>
                <div class="text-center"><input class="btn btn-primary" type="submit" onclick="issue()" value="发布"/></div><br>
      <!--   <div class="text-center"><a  href="#">+继续添加新的回报</a></div> -->
    </div>

</div>
<!--下部-->
<div id="bottom">
    <jsp:include page="/WEB-INF/view/tail.jsp"></jsp:include>
</div>

	<script type="text/javascript">
		function save(){
			var formData = new FormData($("#form")[0]); //用form 表单直接 构造formData 对象; 就不需要下面的append 方法来为表单进行赋值了。 
			$.ajax({
				url : 'product/addrepay',
				type : 'POST',
				async : true,
				data : formData,
				dataType : 'json',
				contentType : false, //必须false才会自动加上正确的Content-Type 
				processData : false, //必须false才会避开jQuery对 formdata 的默认处理   	
				success : function(data) {
					if (data.code == 200) {
						alert("保存错草稿成功");
						window.location.href="/Crowdfunding/product/to/repay";
					} else {
						alert("保存草稿失败,可能未登录");
					}
				},
				error : function(msg) {
					alert("网络异常,保存草稿失败");
				}
			});

		}
		
		function issue(){
			var formData = new FormData($("#form")[0]); //用form 表单直接 构造formData 对象; 就不需要下面的append 方法来为表单进行赋值了。 
			$.ajax({
				url : 'product/projectReleased',
				type : 'POST',
				async : true,
				data : formData,
				dataType : 'json',
				contentType : false, //必须false才会自动加上正确的Content-Type 
				processData : false, //必须false才会避开jQuery对 formdata 的默认处理   	
				success : function(data) {
					alert(data.code);
					if (data.code==200) {
						alert("发布成功,等待审核");
						window.location.href="/Crowdfunding/index.jsp";
					} else {
						alert("发布失败,可能未登录");
					}
				},
				error : function(msg) {
					alert("网络异常,发布失败");
				}
			});

		}
	</script>
	
</body>
</html>